package dyyx;

import java.nio.charset.Charset;

import com.google.common.hash.Hashing;

public class HashTest {
	
	private static final String UTF8 = "UTF8";
	private static final Charset charset = Charset.forName(UTF8);

	
	public static void main(String[] args) throws Exception {		
		
		 String str = "hello,guava,你好";
		 byte[] bytes = str.getBytes(UTF8);
		 
		 System.out.println(Hashing.md5().hashString(str,charset));
		 System.out.println(Hashing.sha256().hashString(str,charset));
		 System.out.println(Hashing.sha512().hashString(str,charset));

		 int buckets = 8;
		 for(int i=0;i<20;i++){
			 long id = i;
			 int bucket = Hashing.consistentHash(id, buckets);
			 System.out.println(id+":"+bucket);
		 }

		
	}
}
